home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / DirectInput / DIConfig / flexcombobox.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-09-27  |  2.4 KB  |  116 lines

  1. //-----------------------------------------------------------------------------
  2. // File: flexcombobox.h
  3. //
  4. // Desc: Implements a combo box control similar to Windows combo box.
  5. //       CFlexComboBox is derived from CFlexWnd.  It is used by the page
  6. //       for player list and genre list.  When the combo box is open,
  7. //       CFlexComboBox uses a CFlexListBox for the list window.
  8. //
  9. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  10. //-----------------------------------------------------------------------------
  11.  
  12. #ifndef __FLEXCOMBOBOX_H__
  13. #define __FLEXCOMBOBOX_H__
  14.  
  15.  
  16. #include "flexlistbox.h"
  17.  
  18.  
  19. #define FCBF_DEFAULT 0
  20.  
  21. enum {
  22.     FCBN_SELCHANGE,
  23.     FCBN_MOUSEOVER
  24. };
  25.  
  26. struct FLEXCOMBOBOXCREATESTRUCT {
  27.     DWORD dwSize;
  28.     DWORD dwFlags;
  29.     DWORD dwListBoxFlags;
  30.     HWND hWndParent;
  31.     HWND hWndNotify;
  32.     BOOL bVisible;
  33.     RECT rect;
  34.     HFONT hFont;
  35.     COLORREF rgbText, rgbBk, rgbSelText, rgbSelBk, rgbFill, rgbLine;
  36.     int nSBWidth;
  37. };
  38.  
  39. class CFlexComboBox : public CFlexWnd
  40. {
  41. public:
  42.     CFlexComboBox();
  43.     ~CFlexComboBox();
  44.  
  45.     // creation
  46.     BOOL Create(FLEXCOMBOBOXCREATESTRUCT *);
  47.  
  48.     // cosmetics
  49.     void SetFont(HFONT hFont);
  50.     void SetColors(COLORREF text, COLORREF bk, COLORREF seltext, COLORREF selbk, COLORREF fill, COLORREF line);
  51.  
  52.     // setup
  53.     int AddString(LPCTSTR);    // returns index
  54.  
  55.     // interaction
  56.     void SetSel(int i);
  57.     int GetSel();
  58.     LPCTSTR GetText();
  59.  
  60. protected:
  61.     virtual void OnPaint(HDC hDC);
  62.     virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  63.  
  64. private:
  65.     HWND m_hWndNotify;
  66.  
  67.     COLORREF m_rgbText, m_rgbBk, m_rgbSelText, m_rgbSelBk, m_rgbFill, m_rgbLine;
  68.     HFONT m_hFont;
  69.     int m_nSBWidth;
  70.     int m_nTextHeight;
  71.     DWORD m_dwFlags;
  72.     DWORD m_dwListBoxFlags;
  73.  
  74.     enum FCBSTATEEVENT {
  75.         FCBSE_DOWN,
  76.         FCBSE_UPBOX,
  77.         FCBSE_UPLIST,
  78.         FCBSE_UPOFF,
  79.         FCBSE_DOWNOFF
  80.     };
  81.  
  82.     enum FCBSTATE {
  83.         FCBS_CLOSED,
  84.         FCBS_OPENDOWN,
  85.         FCBS_OPENUP,
  86.         FCBS_CANCEL,
  87.         FCBS_SELECT
  88.     };
  89.  
  90.     FCBSTATE m_eCurState;
  91.     void StateEvent(FCBSTATEEVENT e);
  92.     void SetState(FCBSTATE s);
  93.     int m_OldSel;
  94.  
  95.     RECT GetRect(const RECT &);
  96.     RECT GetRect();
  97.     RECT GetListBoxRect();
  98.     void SetRect();
  99.     RECT m_rect;
  100.  
  101.     void InternalPaint(HDC hDC);
  102.     
  103.     void Notify(int code);
  104.  
  105.     CFlexListBox m_ListBox;
  106.     BOOL m_bInSelMode;
  107.  
  108.     void DoSel();
  109. };
  110.  
  111.  
  112. CFlexComboBox *CreateFlexComboBox(FLEXCOMBOBOXCREATESTRUCT *pcs);
  113.  
  114.  
  115. #endif //__FLEXCOMBOBOX_H__
  116.